
import logging
import logging.handlers


# 定义logger
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)



def set_log_file(filename,level):
    handler = logging.FileHandler(filename)
    handler.setLevel(level)
    handler.setFormatter(logging.Formatter("%(asctime)s - %(levelname)s - %(filename)s[:%(lineno)d] - %(message)s"))
    logger.addHandler(handler)

set_log_file('logs/error.log',logging.ERROR)
set_log_file('logs/app.log',logging.INFO)

